﻿using System.Collections.Generic;
using Managistics.Model;
using Managistics.Warehouse.Configuration;
using Managistics.Warehouse.Controllers.Interfaces;
using Managistics.Warehouse.Views.Interfaces;
using Managistics.Warehouse.Factories;
using Managistics.Core.Services;

namespace Managistics.Warehouse.Controllers
{
    public class SubController : ISubController
    {
        private readonly IInventoryService inventoryService;

        readonly ISubView subView;
        readonly ComplexParameterObject parameter;

        public SubController(ISubView subView, ComplexParameterObject parameter, IInventoryService inventoryService)
        {
            this.subView = subView;
            this.parameter = parameter;
            this.inventoryService = inventoryService;

            subView.ClickGetParameterButtonClicked += SetText;
            subView.ClickImportRelationsButtonClicked += ExecuteImportRelations;
        }

        public void Run()
        {
            subView.Open();
        }

        public void Stop(string key) { }

        void SetText()
        {
            // parameter PurchaseOrder tu view day
            subView.SetText(parameter.Text);
        }

        void ExecuteImportRelations()
        {
            inventoryService.ImportToCreateRelations(string.Empty, 5);
        }
    }
}